<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    #div1, #div2 {
      width:100px;
      height:50px;
      padding:10px;
      border:1px solid #aaaaaa;
    }
  </style>
</head>
<body>
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
  <span id="drag" draggable="true" ondragstart="drag(event)">drag me to the other box</span>
</div>
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
</body>
<script>

async function throwError() {
  throw new Error('xxxxxxxxxxx')
}

async function testError() {
  try {
    const aaa = await throwError()
  } catch (error) {
    throw error
  }
}

async function __test() {
  testError().then(res => {
    console.log(res)
  }).catch((error) => {
    console.error(error)
  })
}

function test () {
  __test().catch(error => {
    console.log('error: => ', error)
  })
}

test ()

const item = [1, 2, 3, 4].some((value, index, array) => {
  console.log(value, index, array)
  return value > 2
})

  console.log(item)

function func1(arg, next, next2, next3) {
  console.log(1, arg, next, next2, next3)

  next()
}
function func2(arg, next, next2, next3) {
  console.log(2, arg, next, next2, next3)
  next()
}
function func3(arg, next, next2, next3) {
  console.log(3, arg, next, next2, next3)
  next()
}
function func4(arg, next, next2, next3) {
  console.log(4, arg, next, next2, next3)
  console.log(next)
}

function reducer (...arg) {
  return arg.reduce((prev, next) => {
    return (args, __next) => prev(args, () => next(args, __next))
  })
}

// reduce: (
//    func1: (arg, next),
//    func2: (arg, next)
// ) => (args) => func1(args, () => func2(args));
// reduce: (
//    funcA: (arg) => { func1(arg func2: (arg, next)) },
//    func3: (arg, next) => {}
// ) => (args) => funcA(args, () => func3(args));
// reduce: (
//    funcA: (arg,) => { func1(arg func2: (arg, next)) },
//    func3: (arg, next) => {}
// );



// reduce: ((arg, next) => {}, (arg, next) => {}) => {};
// prev: (args) => prev(args, () => next(args));
// prev: (args, next) => prev(args, () => next(args));




function reducer2 (...arg) {
  return (...args) => arg.reverse().reduce((prev, next) => {
    return prev(args, () => next(args))
  })
}

const memder = reducer(func1, func2, func3, func4)

console.log('memder: => ', memder)
memder('xxxxxxxxxxxxxxxxxxxx')
</script>


(((() => {}) => {}) => {}) => {}
</html>
